<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>递归函数的练习</title>
</head>

<body>
    <p>递归函数练习：使用递归的方式计算 1+2+3+···+100 的结果。</p>
    <script>
        var i = 1;
        var sum = 0;
        function Sum() {
            sum = sum + i;
            i++;
            if (i <= 100) {
                Sum();
            }
            return sum;
        }
        document.write(Sum());
    </script>
</body>

</html>